<template>
  <div>
    <cu-nav
      :centerText="centerText"
      :leftIcon="leftIcon"
      :colorIconLeft="colorIconLeft"
      colorIcon="#fff"
      colorText="#fff"
      background="#e8443d"
      rightIconCount="2"
      rightFirstIcon="icon-ic_developer"
      rightSecondIcon="icon-geren"
      :fixed="fixed?fixed:false"
      @click-left="chickLeft"
      @click-right-first="clickRightFirst"
      @click-right-second="clickRightSecond"
    ></cu-nav>
  </div>
</template>
<script>
import CuNav from "@/components/custom-model/cu-nav";
import emitUtil from "@/utils/emitUtil";
export default {
  watch: {
    active: {
      handler(val) {
        this.leftIcon = this.leftIconDefult;
        if (val) {
          this.leftIcon = "icon-rili";
        }
      },
      immediate: true
    }
  },
  props: ["centerText", "active", "fixed"], // 文字
  components: {
    "cu-nav": CuNav
  },
  data() {
    return {
      leftIconDefult: "icon-pinglun1",
      leftIcon: this.leftIconDefult,
      colorIconLeftDefult: "#ffd60c", // 左侧图标颜色
      colorIconLeft: "",
      leftIconSelected: false //左侧图标选择状态，默认false，不选中
    };
  },
  methods: {
    chickLeft(e) {
      if (this.active == 1) {
        this.leftIconSelected = !this.leftIconSelected;
        this.colorIconLeft = this.leftIconSelected ? "#ffd60c" : "";

        // 更新影像显示内容
        emitUtil.$emit("update-image", {
          leftIconSelected: this.leftIconSelected
        });
      } else {
        this.$router.push({
          name: "newsIndex"
        });
      }
    },
    // 我的家族
    clickRightFirst(e) {
      this.$router.push({
        name: "familyList"
      });
    },
    // 个人中心
    clickRightSecond(e) {
      this.$router.push({
        name: "personIndex"
      });
    }
  }
};
</script>

